package com.pk.android.view;

import android.content.Intent;

import com.pk.android.R;
import com.pk.android.model.NavDrawer;
import com.pk.android.model.NavDrawerActivityConfiguration;
import com.pk.android.model.NavDrawerHeader;
import com.pk.android.model.NavDrawerItem;
import com.pk.android.view.adapter.NavDrawerAdapter;

// ## All activities should extend this class. 
// ## NOT THE BaseActivity 
public class GeneralDrawerActivity extends BaseActivity {

	//## SuppressWarnings in case no activity uses the mActivityTitle
	@SuppressWarnings("unused")
	private String mActivityTitle = "ACTIVITY_TITLE";
	
	@Override
 protected NavDrawerActivityConfiguration getNavDrawerConfiguration() {
 	
 	NavDrawer[] menu = getNavigationList();
 	
 	NavDrawerActivityConfiguration navDrawerActivityConfiguration = new NavDrawerActivityConfiguration();
     navDrawerActivityConfiguration.setMainLayout(R.layout.activity_main);
     navDrawerActivityConfiguration.setDrawerLayoutId(R.id.drawer_layout);
     navDrawerActivityConfiguration.setLeftDrawerId(R.id.left_drawer);
     navDrawerActivityConfiguration.setNavItems(menu);
     navDrawerActivityConfiguration.setDrawerShadow(R.drawable.drawer_shadow);      
     navDrawerActivityConfiguration.setDrawerOpenDesc(R.string.drawer_open);
     navDrawerActivityConfiguration.setDrawerCloseDesc(R.string.drawer_close);
     //navDrawerActivityConfiguration.setBaseAdapter(
     //        new NavDrawerAdapter(this, R.layout.navdrawer_item, menu ));
     navDrawerActivityConfiguration.setBaseAdapter(new NavDrawerAdapter(this, menu));
     return navDrawerActivityConfiguration;
 }
 
 
 private NavDrawer[] getNavigationList()
 {

 	NavDrawer[] navList = new NavDrawer[]{
 			
 			NavDrawerHeader.create(100, getResources().getString(R.string.section_my_league), R.drawable.ic_launcher),
 			NavDrawerItem.create(101, getResources().getString(R.string.navigation_all_leagues), getResources().getString(R.string.navigation_all_leagues), R.drawable.ic_drawer, false),
 			NavDrawerItem.create(102,getResources().getString(R.string.navigation_my_leagues), getResources().getString(R.string.navigation_my_leagues), R.drawable.ic_drawer, true), 
 			NavDrawerItem.create(103, getResources().getString(R.string.navigation_my_teams), getResources().getString(R.string.navigation_my_teams), R.drawable.ic_drawer, true), 
 			NavDrawerItem.create(104,getResources().getString(R.string.navigation_create_league), getResources().getString(R.string.navigation_create_league), R.drawable.ic_drawer, true), 
 			NavDrawerItem.create(105, getResources().getString(R.string.navigation_create_team), getResources().getString(R.string.navigation_create_team), R.drawable.ic_drawer, false),
 			
 			NavDrawerHeader.create(200, getResources().getString(R.string.section_cy_league), R.drawable.ic_launcher),
 			NavDrawerItem.create(201,getResources().getString(R.string.navigation_all_leagues), getResources().getString(R.string.navigation_all_leagues), R.drawable.ic_drawer, true),
 			NavDrawerItem.create(201,getResources().getString(R.string.navigation_all_leagues), getResources().getString(R.string.navigation_all_leagues), R.drawable.ic_drawer, false)
 	};

	    return navList;
 }
 
 @Override
 protected void onNavItemSelected(int id) {
 	Intent intent = new Intent();
 	switch (id) {
     case 101:
    	 intent = new Intent(this, MainActivity.class);
         //intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP|Intent.FLAG_ACTIVITY_NO_ANIMATION);
         //intent.putExtra(ACTIVITY_TITLE, "APOEL");
         break;
     case 102:
    	 intent = new Intent(this, MyLeaguesActivity.class);
    	 break;
     case 103:
       	intent = new Intent(this, MyTeamsActivity.class);
        break;
     case 104:
       	intent = new Intent(this, CreateLeagueActivity.class);
       	break;
     case 105:
       	intent = new Intent(this, CreateTeamActivity.class);
       	break;
     default:
     	intent = new Intent(this, MyLeaguesActivity.class);
     	break;
 	}
 	
    startActivity(intent);
    
    overridePendingTransition(android.R.anim.slide_in_left, android.R.anim.slide_out_right);
    
    finish();
 }

}
